package com.lucker.service;

import java.sql.ResultSet;

public class RemoveRerow {

	public static void main(String[] args) {
		
		try {
			
			
			removeRow();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public static void removeRow() throws Exception {
		
		String sql = "select cai_id,issueno,count(1) as ct  from cai_piao_opencode group by cai_id,issueno HAVING ct > 1";
		int count = 1;
		ResultSet ret = JdbcUtil.query(sql);
		while(ret.next()) {
			int ct = ret.getInt("ct");
			String cid = ret.getString("cai_id");
			String qi =  ret.getString("issueno");
			String sql2 = "select id from cai_piao_opencode where cai_id = "+cid+" and issueno = '"+qi+"'";
			ResultSet ret2 = JdbcUtil.query(sql2);
			if(ret2.next()) {
				int id = ret2.getInt("id");
				if(id > 0) {
					
					String sql3 = "delete from cai_piao_opencode where id = " + id;
					System.out.println(count+":::"+sql3);
					JdbcUtil.exe(sql3);
					
					count ++;
				}
			}
			
			
			
			
			
		}
		
		
		
		
	}

}
